if (x > fade_area_topleft[0] && x < fade_area_bottomright[0] &&
y > fade_area_topleft[1] && y < fade_area_bottomright[1]) {
float ratio = 1.0;
+ float fade_top_start = fade_area_topleft[1] + vfade_offset;
+ float fade_left_start = fade_area_topleft[0] + hfade_offset;
float fade_bottom_start = fade_area_bottomright[1] - vfade_offset;
float fade_right_start = fade_area_bottomright[0] - hfade_offset;
bool fade_top = y < vfade_offset && fade_edges_top;
bool fade_bottom = y > fade_bottom_start && fade_edges_bottom;
- bool fade_left = x < hfade_offset && fade_edges_left;
+ bool fade_left = x < fade_left_start && fade_edges_left;
bool fade_right = x > fade_right_start && fade_edges_right;
float vfade_scale = height / vfade_offset;
if (fade_top) {
- ratio *= y / vfade_offset;
+ ratio *= (fade_area_topleft[1] - y) / (fade_area_topleft[1] - fade_bottom_start);
}
if (fade_bottom) {
float hfade_scale = width / hfade_offset;
if (fade_left) {
- ratio *= x / hfade_offset;
+ ratio *= (fade_area_topleft[0] - x) / (fade_area_topleft[0] - fade_left_start);
}
if (fade_right) {